package com.cbank.service;

import com.cbank.dao.ModuleDao;
import com.cbank.domain.Module;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ModuleService {
    private Logger logger=Logger.getLogger(ModuleService.class);

    @Autowired
    private ModuleDao moduleDao;

    public List<Module> getAll(){ return this.moduleDao.getAll(); }

    public Module getById(Integer id){
        return this.moduleDao.getById(id);
    }

    public Module getByViewId(String viewId){
        return this.moduleDao.getByViewId(viewId);
    }

    public void save(Module module){
        Module modu=this.moduleDao.getById(module.getId());
        if (modu == null){
            this.moduleDao.insert(module);
        }else {
            this.moduleDao.update(module);
        }
    }
}
